/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.googlecode.entityCollection;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

/**
 *
 * @author italo
 */
public class Record {
    
    private File file;
    private FileWriter writer;
    private PrintWriter grava;
    private FileReader reader;
    private BufferedReader leitor;
    
    public Record(Object o) throws IOException{
        this.file = new File("db.txt");
        this.writer = new FileWriter(o.toString()+".txt", true);
        this.grava = new PrintWriter(writer, true);
        this.reader = new FileReader(o.toString()+",txt");
        this.leitor = new BufferedReader(reader,1*1024*1024);
    }
    
    public void rec(Object o) throws IOException{
        this.grava.print(o);
        writer.close();
        grava.close();
    }
    
    public void read() throws FileNotFoundException, IOException{
        String linha = null;  
        while(leitor.readLine() != null) {  
            System.out.println("Linha: " + linha);  
        }   

        
    }

}
